<?php
session_start();
include "../db_connect.php";

$type = $_POST['type'];
$hasotid = "match";
if($type = "d")
{
$otid = $_POST['otid'];
$delete_id = $_POST['delete_id'];

$sql = mysql_query("SELECT * FROM forum_posts WHERE id = '$delete_id'");
$numrows= mysql_num_rows($sql);	
	if($numrows <1)
	{
	echo "all ready remove from the forum";
	//echo $delete_id ."+". $type;
	exit();
	}
	else
	{
		$mysql = mysql_query("SELECT * FROM forum_posts WHERE id = '$delete_id'");
		while($row = mysql_fetch_array($mysql))
		{
			if(checker() == "onematchfound")
			{
			mysql_query("DELETE FROM forum_posts WHERE id='$delete_id'");
			echo "otid>>> ". $otid ."id>>> ". $delete_id;
			}
			else if(checker() == "manymantchfound")
			{
			//mysql_query("DELETE FROM forum_posts WHERE id='$delete_id'");
			mysql_query("DELETE FROM forum_posts WHERE id='$delete_id'");
			mysql_query("DELETE FROM forum_posts WHERE otid='$delete_id'");

			echo "otid gege>>> ". $otid ."id>>> ". $delete_id;
			}
			
		
		}
		
		
		
	
	}

}

function checker()
{
$delete_id = $_POST['delete_id'];
$sql = mysql_query("SELECT * FROM forum_posts WHERE otid = '$delete_id'");
$numrows= mysql_num_rows($sql);
	
	if($numrows < 1)
	{
	return "onematchfound";
	}
	else
	{
	return "manymantchfound";
	}

}

?>